<?php

class Group extends CActiveRecord
{
	public $userid;
	public $cateid;
	
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	public function tableName()
	{
		return '{{group}}';
	}

	public function rules()
	{
		return array(
			array('groupname,groupdesc','required'),
			array('groupname', 'length', 'max'=>64),
			array('groupdesc', 'length', 'max'=>2000),
			array('groupname','unique'),
		);
	}
	


	/**
	 * (non-PHPdoc)
	 * @see CModel::attributeLabels()
	 */
	public function attributeLabels()
	{
		return array(
			'groupname' => '小组名称',
			'groupdesc' => '小组介绍',
		);
	}

	/**
	 * (non-PHPdoc)
	 * @see CActiveRecord::beforeSave()
	 */
	public function beforeSave()
	{
		if(parent::beforeSave())
		{
			if($this->isNewRecord)
			{
				$this->userid = Yii::app()->user->id;
				$this->addtime=date('Y-m-d H:i:s');
			}
			return true;
		}
		else
			return false;
	}

}